package com.cgnpc.scp.config;

import com.cgnpc.cud.core.domain.AjaxResult;
import com.cgnpc.scp.common.utils.AjaxResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/******************************
 * 用途说明: 异常处理
 * 作者姓名: chenshijie
 * 创建时间: 2020/11/30 17:18
 ******************************/
@ControllerAdvice
public class ControllerExceptionAdvice {

    private static final Logger LOGGER = LoggerFactory.getLogger(ControllerExceptionAdvice.class);

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public AjaxResult errorHandler(Exception ex) {
        LOGGER.error("截获未捕捉异常",ex);
        return AjaxResultUtil.createErrorMessage("params error.please try agent.");
    }
}
